#include <stdio.h>
#include <stack>
#include <string.h>

using namespace std;

const int size = 1000;

int main( )
{
    stack<int> s1, s2;
    int n, i, j, l1, l2;
    char in[ size ], out[ size ];
    while ( scanf("%d", &n) != EOF )
    {
        scanf("%s%s", in, out);
        l1 = strlen( in );
        l2 = strlen( out );
        i = j = 0;
        while ( !s1.empty( ) )
            s1.pop( );
        while ( !s2.empty( ) )
            s2.pop( );
        s1.push( in[ 0 ] );
        s2.push( out[ 0 ] );
        while ( i < l1 && j < l2 )
        {
            if ( s1.top( ) != s2.top( ) )
            {
                i++;
                s1.push( in[ i ] );
            }
            else
            {
                s1.pop( );
                s2.pop( );
                j++;
                if ( j < l2 )
                {
                    s2.push( out[ j ] );
                    if ( s1.empty( ) && i < l1 - 1 )
                    {
                        i++;
                        s1.push( in[ i ] );
                    }
                }
            }
        }
        if ( s1.empty( ) && s2.empty( ) )
        {
            printf("Yes.\n");
            while ( !s1.empty( ) )
                s1.pop( );
            while ( !s2.empty( ) )
                s2.pop( );
            i = j = 0;
            s1.push( in[ 0 ] );
            s2.push( out[ 0 ] );
            printf("in\n");
            while ( i < l1 && j < l2 )
            {
                if ( s1.top( ) != s2.top( ) )
                {
                    i++;
                    s1.push( in[ i ] );
                    printf("in\n");
                }
                else
                {
                    s1.pop( );
                    s2.pop( );
                    j++;
                    s2.push( out[ j ] );
                    printf("out\n");
                    if ( s1.empty( ) && i < l1 - 1 )
                    {
                        i++;
                        s1.push( in[ i ] );
                        printf("in\n");
                    }
                }
            }
            printf("FINISH\n");
        }
        else
            printf("No.\nFINISH\n");
    }
    return 0;
}
